package com.firefightingiot.firefightingiot.config.scheduling;

import com.firefightingiot.firefightingiot.web.mapper.statistics.DeviceAlarmLogAllStatisticsWeekMapper;
import com.firefightingiot.firefightingiot.web.service.HomeDataService;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;

import javax.annotation.Resource;

/**
 * 继承Application接口后项目启动时会按照执行顺序执行run方法
 * 通过设置Order的value来指定执行的顺序
 * 处理事项：检索统计表里边是不是有数据，没有最好初始化数据
 * 只启动一次，之后注掉，或者通过一个表来控制，在晚上12点之前上线项目，只要避开零点-零点30就可以
 */
//@Component
//@Order(value = 1)
public class StartService implements ApplicationRunner {

    @Resource
    HomeDataService homeDataService;
    @Resource
    private DeviceAlarmLogAllStatisticsWeekMapper deviceAlarmLogAllStatisticsWeekMapper;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        //查询全部日志数据周分析统计表
//        int allStatisticsWeekCount = deviceAlarmLogAllStatisticsWeekMapper.selectCount(new QueryWrapper<>());
//        if(allStatisticsWeekCount == 0){//说明没有数据，这是第一次导入到相关统计表
//            homeDataService.insertLogStatisticsForOne();
//        }

    }


}
